package com.android.youwenchuang.presenter;

import android.text.TextUtils;

import com.android.youwenchuang.App;
import com.android.youwenchuang.base.IPresenter;
import com.android.youwenchuang.bean.Goods;
import com.android.youwenchuang.gen.GoodsDao;

import java.util.List;

public class SearchPresenter implements IPresenter {

    public List<Goods> getGoodsList(String searchText) {
        GoodsDao goodsDao = App.mApp.getDaoSession().getGoodsDao();
        if (TextUtils.isEmpty(searchText)) {
            return goodsDao.loadAll();
        } else {
            return goodsDao.queryBuilder().where(GoodsDao.Properties.Name.like("%" + searchText + "%")).list();
        }
    }
}
